package com.dict.mybatis.lab.controller;


import com.dict.mybatis.lab.entity.User;
import com.dict.mybatis.lab.entity.User2;
import com.dict.mybatis.lab.enums.EducationEnum;
import com.dict.mybatis.lab.enums.SexEnum;
import com.dict.mybatis.lab.service.IUserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping(value = "/user")
public class UserController {

    @Resource
    private IUserService userService;

    @RequestMapping("findUsers")
    public List<User> findUsers() {
        return userService.findUsers();
    }


    @RequestMapping("finUserById/{id}")
    public User finUserById(@PathVariable("id") Long id) {
        return userService.findUserById(id);
    }

    @RequestMapping("insert")
    public String insert() {
        User user = new User("奥德彪", SexEnum.MAN, new Date(), EducationEnum.HIGH_SCHOOL, new Date(), new Date());
        Long aLong = userService.insertUer(user);
        return "表主键自增获取到的新增用户id为：" + user.getId() + "返回值：" + aLong;
    }

    @RequestMapping("uuid/insert")
    public String insertUUID() {
        User2 user2 = new User2("", "奥德彪", "F", "12255558888");
        Long aLong = userService.insertUUID(user2);
        return "表uuid主键获取到的新增用户id为：" + user2.getId() + "返回值：" + aLong;
    }
}